//
//  MHDiscoverContainerViewController.m
//  MiaoCircle
//
//  Created by 许正荣 on 2018/9/21.
//  Copyright © 2018年 acgera. All rights reserved.
//

#import "MHDiscoverContainerViewController.h"
#import "MHDiscoverHomeViewController.h"
#import "MHDiscoverHomeViewModel.h"
#import "MHNearCollectionViewModel.h"
#import "MHNearByCollectionViewController.h"
#import "MHNearByHomeTableViewModel.h"
#import "MHNearByHomeCollectionViewController.h"
@interface MHDiscoverContainerViewController ()

@end

@implementation MHDiscoverContainerViewController



- (void)viewDidLoad {
    if (self.titles == nil) {
        _titles = @[ @"附近",@"推荐",];
    }
    
    [super viewDidLoad];
    self.myCategoryView.averageCellSpacingEnabled = YES;
    self.myCategoryView.cellSpacing =  0;
    self.myCategoryView.titleFont = MHRegularFont_18;
    self.myCategoryView.titles = self.titles;
    self.myCategoryView.titleColor = MHMetionTextColor;
    self.myCategoryView.titleSelectedColor = MHTextColor333;
    self.navigationItem.titleView = self.myCategoryView;

    JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
    lineView.indicatorLineWidth = JXCategoryViewAutomaticDimension;
    lineView.lineStyle = JXCategoryIndicatorLineStyle_JD;
    lineView.indicatorLineViewColor = MHColorFromHexString(@"#FF0117");
    lineView.verticalMargin = 5;
    self.myCategoryView.indicators = @[lineView];

}

-(UIViewController *)preferredCategoryViewControllerWithIndex:(int)index
{
    if (index == 0) {
        MHNearByHomeTableViewModel *nearViewModel =   [[MHNearByHomeTableViewModel alloc] initWithServices:self.viewModel.services params:@{@"MHViewModelShowLocation": @(YES)}];
        MHNearByHomeCollectionViewController *nearByVc= [[MHNearByHomeCollectionViewController alloc] initWithViewModel:nearViewModel];
        return nearByVc;
       
    }else
    {
        MHDiscoverHomeViewController *discover = [[MHDiscoverHomeViewController alloc] initWithViewModel:  [[MHDiscoverHomeViewModel alloc] initWithServices:self.viewModel.services params:@{@"MHViewModelShowLocation": @(NO)}]];
        return discover;
    }
}

- (CGFloat)preferredCategoryViewHeight {
    return 0.01;
}



- (JXCategoryTitleView *)myCategoryView {
    return (JXCategoryTitleView *)self.categoryView;
}

- (NSUInteger)preferredListViewCount {
    return self.titles.count;
}

- (Class)preferredCategoryViewClass {
    return [JXCategoryTitleView class];
}

@end
